package com.shuqi.model.parse.parser;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import android.text.TextUtils;

import com.shuqi.model.bean.AppUpdateInfo;
import com.shuqi.model.parse.HandlerBase;

/**
 * 解析设置界面需要的联网数据
 * 
 * @author linyuren
 * 
 */
public class UserSettingParser extends HandlerBase {

    private AppUpdateInfo info;

    public void startDocument() throws SAXException {
        this.info = new AppUpdateInfo();
    }

    public void startElement(String namespaceURI, String localName, String qName, Attributes attrs)
            throws SAXException {
        if (localName.equals("update")) {
            this.info.setVersion(attrs.getValue("version"));
            this.info.setUpdate_url(attrs.getValue("url"));
            String intro = attrs.getValue("intro");
            if(!TextUtils.isEmpty(intro)){
                this.info.setIntro(intro.replaceAll("br@@", "\n"));
            }
            this.info.setVersion2(attrs.getValue("version2"));
            this.info.setUpdate_url2(attrs.getValue("url2"));
            String intro2 = attrs.getValue("intro2");
            if(!TextUtils.isEmpty(intro2)){
                this.info.setIntro2(intro2.replaceAll("br@@", "\n"));
            }
            this.info.setShowWeb(attrs.getValue("showWeb"));
        }
    }

    public AppUpdateInfo getParsedData() {
        return this.info;
    }

}
